$(function(){
    var datatable = $('#listTable').DataTable({
        // paging: true,
        searching: false,
        ordering: false,
        // serverSide: true,
        deferRender: true,
        bProcessing: true,
        bDeferLoading: true,
        orderMulti: false,

        ajax: {
            "url": "/seckill/listBody",
            "type": "POST",
            "dataSrc": "content",
            "dataType": "JSON",
            "data": function (d) {
                d.page = (d.start / d.length);
                d.size = d.length;
            }
        },

        aoColumns: [
            {"mData": "name"},
            {"mData": "number"},
            {
                "mData": "startTime",
                "render": function (data, type, row, meta) {
                    if (!data) {
                        return "";
                    }
                    return new Date(data).format("yyyy-MM-dd hh:mm:ss");
                }
            },
            {
                "mData": "endTime",
                "render": function (data, type, row, meta) {
                    if (!data) {
                        return "";
                    }
                    return new Date(data).format("yyyy-MM-dd hh:mm:ss");
                }
            },
            {
                "mData": "createTime",
                "render": function (data, type, row, meta) {
                    if (!data) {
                        return "";
                    }
                    return new Date(data).format("yyyy-MM-dd hh:mm:ss");
                }
            },
            {
                "mData": "seckillId",
                "render": function (data, type, row, meta) {
                    return "<a class=\"btn btn-info\" href=\"/seckill/" + data + "/detail\" target=\"_blank\">详情</a>";
                }
            }
        ],

        // fnInitComplete: function () {
        //     this.fnAdjustColumnSizing(true);
        // },
        pagingType: "simple_numbers",
        pageLength: 10,
        lengthMenu: [
            [10, 25, 50, 100],
            [10, 25, 50, 100]
        ],
        oLanguage: {
            sLengthMenu: "每页显示 _MENU_ 条",
            sZeroRecords: "没有找到符合条件的数据",
            sProcessing: "正在加载数据...",
            sInfo: "_START_-_END_ 条 / 共 _TOTAL_ 条",
            sInfoEmpty: "没有记录",
            oPaginate: {
                sPrevious: "<i class='fa fa-chevron-left'></i>",
                sNext: "<i class='fa fa-chevron-right'></i>"
            }
        },
        dom: 'lfrtip',
        bAutoWidth: true
    });
});